from tool.wechat import WeChat
import datetime
from tool.config import read_config


def main(config_file_path):

    notice_time = read_config(config_file_path)['notice_time']['notice_time']
    notice_time_list = None
    try:
        notice_time_list = eval(notice_time)
    except Exception as e:
        print(f'更新AccessToken错误,原因{e},请检查配置文件的notice_time')
        exit()

    while True:

        for notice in notice_time_list:
            i = str(datetime.datetime.now())
            now_time = i.split(" ")[1][0:5]

            if str(notice) == now_time:
                print(now_time, "发送>>>>>>")
                WeChat(config_file_path).send_msg()
                while True:
                    i = str(datetime.datetime.now())
                    now_time = i.split(" ")[1][0:5]

                    if str(notice) != now_time:
                        break


if __name__ == '__main__':
    main(r"./config/parameter - 副本.cfg")
